package com.example.demo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.entity.PurchaseOrder;
import com.example.demo.service.IPurchaseOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author cici
 */
@RestController
@Api(tags = "采购单相关接口")
@RequestMapping("/purchase")
public class PurchaseOrderController {

    @Autowired
    private IPurchaseOrderService purchaseOrderService;

    @PostMapping(value = "/create")
    @ApiOperation(value = "新增", notes = "传入purchaseOrder")
    public PurchaseOrder create(@RequestBody PurchaseOrder purchaseOrder){
        return purchaseOrderService.create(purchaseOrder);
    }

    @GetMapping(value = "/detail/{id}")
    @ApiOperation(value = "查询", notes = "传入id")
    public PurchaseOrder detail(@PathVariable("id") Integer id){
        return purchaseOrderService.detail(id);
    }

    @GetMapping(value = "/page")
    @ApiOperation(value = "查询", notes = "传入id")
    public IPage<PurchaseOrder> page(Page<PurchaseOrder> page,PurchaseOrder purchaseOrder){
        return purchaseOrderService.selectPage(page,purchaseOrder);
    }

}
